package com.ruoyi.workflow.dubbo;

import com.ruoyi.workflow.api.RemoteProcessInstanceService;
import com.ruoyi.workflow.api.model.bo.StartProcessBo;
import com.ruoyi.workflow.service.IActProcessInstanceService;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 流程实例管理
 *
 * @author gssong
 */
@RequiredArgsConstructor
@Service
@DubboService
public class RemoteProcessInstanceServiceImpl implements RemoteProcessInstanceService {

    private final IActProcessInstanceService iActProcessInstanceService;

    /**
     * @description: 获取流程实例id
     * @param: businessKey
     * @return: java.lang.String
     * @author: gssong
     * @date: 2022/12/10 13:42
     */
    @Override
    public String getProcessInstanceId(String businessKey) {
        return iActProcessInstanceService.getProcessInstanceId(businessKey);
    }

    /**
     * @description: 删除运行中的实例，删除历史记录，删除业务与流程关联信息
     * @param: processInstanceId
     * @return: boolean
     * @author: gssong
     * @date: 2022/12/10 13:43
     */
    @Override
    public boolean deleteRuntimeProcessAndHisInst(String processInstanceId) {
        return iActProcessInstanceService.deleteRuntimeProcessAndHisInst(processInstanceId);
    }

    /**
     * @description: 启动流程实例
     * @param: startProcessBo
     * @return: java.util.Map<java.lang.String,java.lang.Object>
     * @author: gssong
     * @date: 2022/12/13 22:25
     */
    @Override
    public Map<String, Object> startWorkFlow(StartProcessBo startProcessBo) {
        return iActProcessInstanceService.startWorkFlow(startProcessBo);
    }
}
